class_name Player
extends CharacterBody2D

@export var player_stats: PlayerStats

@onready var animator: AnimatedSprite2D = %Animator

@onready var player_input_handler: PlayerInputHandler = %PlayerInputHandler

@onready var player_state_machine: PlayerStateMachine = %PlayerStateMachine

@onready var player_state_checker: PlayerStateChecker = %PlayerStateChecker

@onready var player_tag_manager: PlayerTagManager = %PlayerTagManager

@onready var jump_ability: JumpAbility = %JumpAbility

var face_direction: float = 1


func _ready() -> void:
	player_state_machine.on_setup()
	jump_ability.on_setup()


func _process(delta: float) -> void:
	print(player_tag_manager.get_all_tags())

	player_state_checker.on_update(delta)
	player_state_machine.on_update(delta)
	player_input_handler.on_update(delta)
	jump_ability.on_update(delta)

	process_abilities()

	move_and_slide()


func process_abilities() -> void:
	if player_input_handler.jump_input:
		jump_ability.try_apply()


func flip() -> void:
	face_direction = -face_direction
	scale.x = -scale.x
